package com.study.spmongodb.controller;

import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * @author MI
 * @version 1.0
 * @date 2020/10/14 15:38
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    HttpServletRequest request;

    @GetMapping
    public Date head() {
        //获取请求头
        final String header = request.getHeader("");

        return new Date();
    }

    @GetMapping("/att")//
    public String att(@ModelAttribute RequestVO requestVO) {
        System.out.println(requestVO);
        final String random = RandomStringUtils.randomAlphabetic(5);
        System.out.println(random);
        return random;
    }

}
